// store
import { defineStore } from 'pinia'
import { store } from '../index'
export const useKeepPageStore = defineStore({
  id: 'KeepPage',
  state: () => ({
    includePages: [] as string[],
    scrollTop: 0
  }),
  actions: {
    addIncludePage(pageName: string) {
      if (!this.includePages.includes(pageName)) {
        this.includePages.push(pageName)
      } // 记住当前的滚动距离
      this.scrollTop = window.scrollY
    },
    removeIncludePage(pageName: string) {
      this.includePages = this.includePages.filter((item) => item !== pageName)
      this.scrollTop = 0
    }
  }
})
export function useKeepPageStoreWithOut() {
  return useKeepPageStore(store)
}
